package com.ymatou.query.trading.api.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.ymatou.query.seller.trading.api.parameter.ExportSellerOrderInfosResponse;
import com.ymt.base.YmatouBaseCall;
import com.ymt.core.tool.FormatUtil;
import com.ymttest.utils.DataUtil;
import com.ymttest.utils.EnvSetup;
/**
*查询国内段未发货的拼邮订单接口Call
*FreeMaker Template自动生成代码
*/
public class GetPackageDeliveryOrdersCountCall extends YmatouBaseCall{
	private static String opurl ="api/SellerQuery/GetPackageDeliveryOrdersCount";
	
	public GetPackageDeliveryOrdersCountCall() {
		super(EnvSetup.getSystemUrl("api_order_query"),opurl,"GET","PARAM");
	}
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	
	/**
	 * 获取shangouOrdersCount
	 * 
	 * @return
	 */
	public String getShangouOrdersCount() {
		String shangouOrdersCount = null;
		try {
			shangouOrdersCount = ((JSONObject) getData())
					.getString("ShangouOrdersCount");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return shangouOrdersCount;
	}
	
	
	/**
	 * 获取SpotOrdersCount
	 * 
	 * @return
	 */
	public String getSpotOrdersCount() {
		String SpotOrdersCount = null;
		try {
			SpotOrdersCount = ((JSONObject) getData())
					.getString("SpotOrdersCount");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return SpotOrdersCount;
	}
	
	/**
	 * 获取totalOrdersCount
	 * 
	 * @return
	 */
	public String getTotalOrdersCount() {
		String TotalOrdersCount = null;
		try {
			TotalOrdersCount = ((JSONObject) getData())
					.getString("TotalOrdersCount");
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return TotalOrdersCount;
	}
	
//	/**
//	 * @return
//	 */
//	public String getShangouOrdersCount() {
//		String shangouOrdersCount = "";
//		try {
//			String shangouOrders= new JSONObject(getString("Data")).getString("ShangouOrdersCount");
//			shangouOrdersCount = (String) new Gson().fromJson(shangouOrders,new TypeToken<String>(){}.getType());
//		} catch (Exception e) {
//			e.printStackTrace();
//		}
//		return shangouOrdersCount;
//	}

	
	/**
	 * 获取Code
	 * 
	 * @return
	 */
	public String getCode() {
		String Code = null;
		try {
			Code = new JSONObject(getReturnData()).getString("Code");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Code;
	}

	/**
	 * 获取BCode
	 * 
	 * @return
	 */
	public String getBCode() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("BCode");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	/**
	 * 获取Msg
	 * 
	 * @return
	 */
	public String getMsg() {
		String BCode = null;
		try {
			BCode = new JSONObject(getReturnData()).getString("Msg");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return BCode;
	}

	public ExportSellerOrderInfosResponse getExportSellerOrderInfosResponse() {
		ExportSellerOrderInfosResponse response = null;
		try {
			response = (ExportSellerOrderInfosResponse) FormatUtil
					.GSONToObject(
							DataUtil.Json.parseJsonObj(
									new JSONObject(getReturnData()).get("Data")
											.toString()).toString(),
							ExportSellerOrderInfosResponse.class);
		} catch (Exception e) {
			e.printStackTrace();
		}
		return response;
	}

	/**
	 * 获取Data
	 * 
	 * @return
	 */
	public Object getData() {
		Object Data = null;
		try {
			Data = new JSONObject(getReturnData()).get("Data");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}
	
	/**
	 * 获取Trace
	 * 
	 * @return
	 */
	public Object getTrace() {
		Object Data = null;
		try {
			Data = new JSONObject(getReturnData()).get("Trace");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Data;
	}

}